<%@ page import="com.informet.ipd.modelo.dao.MATareaDao"%>
<%@ page import="com.informet.ipd.modelo.vo.MATareaVO" %>
<%@ page import="com.informet.ipd.modelo.vo.MATareaMVO" %>
<%@ page import="com.informet.ipd.struts.form.PEIForm" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.swing.JOptionPane"%>
<%@ page language="java"  pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/tags/c" prefix="c"%>

<%

   
            StringBuffer cadenaSalida = new StringBuffer();
            List lista = null;
             int   fkTarea = Integer.parseInt(request.getParameter("fkTarea"));
          
            MATareaDao dao = new MATareaDao();
            PEIForm form1 = new PEIForm();
            MATareaVO vo = null;
            try {
             int tipo = Integer.parseInt(request.getParameter("tipo"));
                if (tipo>0) {
                    int pk = Integer.parseInt(request.getParameter("pk"));
                    double mes1 = Double.parseDouble(request.getParameter("mes1"));
                    double mes2 = Double.parseDouble(request.getParameter("mes2"));
                    double mes3 = Double.parseDouble(request.getParameter("mes3"));
                    double mes4 = Double.parseDouble(request.getParameter("mes4"));
                    double mes5 = Double.parseDouble(request.getParameter("mes5"));
                    double mes6 = Double.parseDouble(request.getParameter("mes6"));
                    double mes7 = Double.parseDouble(request.getParameter("mes7"));
                    double mes8 = Double.parseDouble(request.getParameter("mes8"));
                    double mes9 = Double.parseDouble(request.getParameter("mes9"));
                    double mes10 = Double.parseDouble(request.getParameter("mes10"));
                    double mes11 = Double.parseDouble(request.getParameter("mes11"));
                    double mes12 = Double.parseDouble(request.getParameter("mes12"));
                    int tipoMedicion = Integer.parseInt(request.getParameter("tipoMedicion"));






                      
                         MATareaVO voMan = new MATareaVO(pk, mes1, mes2, mes3, mes4, mes5, mes6, mes7, mes8, mes9, mes10, mes11, mes12, fkTarea,tipoMedicion);
                         dao.spMan(tipo, voMan);
                     
                    


                }
                lista = dao.getListById(fkTarea);
                form1.setListaMeATa(lista);
                cadenaSalida.append("<table id='tabla1' width='99%' align='right' class='userTable'>");
                cadenaSalida.append("<tr class='even' align='center'>");
                cadenaSalida.append("<th class='textoTR'>#</th>");
                cadenaSalida.append("<th class='textoTR'>Meta</th> ");
                cadenaSalida.append("<th class='textoTR'>Enero</th> ");
                cadenaSalida.append("<th class='textoTR'>Febrero</th> ");
                cadenaSalida.append("<th class='textoTR'>Marzo</th> ");
                cadenaSalida.append("<th class='textoTR'>Abril</th> ");
                cadenaSalida.append("<th class='textoTR'>Mayo</th> ");
                cadenaSalida.append("<th class='textoTR'>Junio</th> ");
                cadenaSalida.append("<th class='textoTR'>Julio</th> ");
                cadenaSalida.append("<th class='textoTR'>Agosto</th> ");
                cadenaSalida.append("<th class='textoTR'>Setiembre</th> ");
                cadenaSalida.append("<th class='textoTR'>Octubre</th> ");
                cadenaSalida.append("<th class='textoTR'>Noviembre</th> ");
                cadenaSalida.append("<th class='textoTR'>Diciembre</th> ");
                cadenaSalida.append("<th class='textoTR'>Editar</th>");
                cadenaSalida.append("<th class='textoTR'>Eliminar</th> ");
                cadenaSalida.append("</tr>");
                  int i=1;
                  int flag1=0;
                Iterator it = lista.iterator();
                while (it.hasNext()) {
                    vo = (MATareaVO) it.next();
                    cadenaSalida.append("<tr align='center'> ");
                    cadenaSalida.append("<td width='10%' align='center'>" +i++ + "</td>");

                    //cadenaSalida.append("<td style='width:1500px;text-align: left' align='center' > "+ vo.getTX_DESCATAREA() + "</td>");


                    
                    //if(vo.getTX_TIPOATAREA1()==1){
                 
                    //cadenaSalida.append("<td width='10%' align='center'>" + (vo.getNUM_MES1MEATA() + vo.getNUM_MES2MEATA() + vo.getNUM_MES3MEATA()
                     //       + vo.getNUM_MES4MEATA() + vo.getNUM_MES5MEATA() + vo.getNUM_MES6MEATA() + vo.getNUM_MES7MEATA() + vo.getNUM_MES8MEATA() + vo.getNUM_MES9MEATA() + vo.getNUM_MES10MEATA()
                       //     + vo.getNUM_MES11MEATA() + vo.getNUM_MES12MEATA()) + "</td>");
                    //}else{
                    
                    //	cadenaSalida.append("<td width='10%' align='center'>" +dao.mayor(vo)+"</td>");
                    //}

                    //cadenaSalida.append("<td width='10%' align='center'>" + vo.getTX_UMAATAREA() + "</td>");

                    if(vo.getTX_TIPOATAREA1()==1){
                    cadenaSalida.append("<td width='10%' align='center'>Acumulado</td>");
                    }else{
                    cadenaSalida.append("<td width='10%' align='center'>Permanente</td>");
                    }
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES1MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES2MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES3MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES4MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES5MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES6MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES7MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES8MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES9MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES10MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES11MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + vo.getNUM_MES12MEATA() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>");
                    cadenaSalida.append("<img style='cursor:pointer' title='Editar' alt='Editar' border=0  src='images/b_edit.png' onclick=\"editarT('" + vo.getNUM_MEATA_PK() + "','" + vo.getNUM_MES1MEATA() + "','" + vo.getNUM_MES2MEATA() + "','" + vo.getNUM_MES3MEATA() + "','" + vo.getNUM_MES4MEATA() + "','" + vo.getNUM_MES5MEATA() + "','" + vo.getNUM_MES6MEATA() + "','" + vo.getNUM_MES7MEATA() + "','" + vo.getNUM_MES8MEATA() + "','" + vo.getNUM_MES9MEATA() + "','" + vo.getNUM_MES10MEATA() + "','" + vo.getNUM_MES11MEATA() + "',' " + vo.getNUM_MES12MEATA() +"','"+vo.getTX_TIPOATAREA1()+"');\">");
                    cadenaSalida.append("</td>");
                    cadenaSalida.append("<td width='10%' align='center'> ");
                    cadenaSalida.append("<img style='cursor:pointer' title='Eliminar' alt='Eliminar' border=0  src='images/b_drop.png' onclick=\"eliminar('" + vo.getNUM_MEATA_PK() + "');\" >");
                    cadenaSalida.append("</td>");
                    cadenaSalida.append("</tr>");
                    cadenaSalida.append("</table>");
                    
                    
                }
            } catch (Exception e) {
                cadenaSalida.append(e.toString());

            }
            out.print(cadenaSalida);
     
%>
